#pragma once

#include "CxType.h"
#include "CxBranchThread.h"
#include "CxImgProcThread.h"
#include "CxRevThread.h"
#include "CxDBThread.h"
#include "CxTcpClient.h"

#include <string>
#include <vector>
#include <boost/signals2/signal.hpp>
#include <boost/signals2.hpp>
#include <boost/thread.hpp>

class CxSystemBuilder
{

    typedef boost::signals2::signal<void(const cv::Mat&)>       _showFunc;
    typedef boost::signals2::signal<void(int,int)>              _showcountFunc;
    typedef boost::signals2::signal<void(bool)>                 _connectFunc;

public:
    CxSystemBuilder();
    ~CxSystemBuilder();
public:
    //signals
    static  _showFunc               sig_showFunc[4];
    static  _showcountFunc          sig_showcountFunc[4];
    static  _connectFunc            sig_dbconnectFunc[4];

private:

    void        BuildPart();


public:
    bool        OpenPort(size_t ,const std::string &,size_t  ,DataRevPart::CxRevThread::_ConnectFunc _func=__EmptyFunc);


    static  void        DestoryPart();
private:
    static  bool        s_isBuilded;

    static  volatile size_t      s_sysRef;

    static  std::vector<CxBranchThread*>                   s_branchInst;
    static  std::vector<DataRevPart::CxRevThread*>         s_revInst;
    static  std::vector<CxImgProcThread*>                  s_imgprocInst;
    static  std::vector<CxDBThread*>                       s_dbInst;

    static  boost::mutex                                    s_mu;
};

